//
//  FFBaseViewController.m
//  LoveAssistant
//
//  Created by nono on 16/8/25.
//  Copyright © 2016年 nono. All rights reserved.
//

#import "FFBaseViewController.h"
#import "FFDefine.h"

@interface FFBaseViewController ()

@end

@implementation FFBaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

//- (void)setIsLogin:(BOOL)isLogin
//{
//    _isLogin = isLogin;
//    if (!isLogin) {
//        FFPresent(@"KCLoginController", nil, self.loginNeedAnim);
//    }
//}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)setNavbarColor:(UIViewController *)viewController color:(UIColor *)color
{
    viewController.navigationController.navigationBar.barTintColor = color;
}

- (void)setNavbarColor:(UIViewController *)viewController
{
    [self setNavbarColor:viewController color:[UIColor colorWithHexString:@"2ab2ff"]];
}


- (void)setNavTitleView:(NSString *)title viewController:(UIViewController *)viewController
{
    [self setNavTitleView:title viewController:viewController fontColor:[UIColor whiteColor] fontSize:20];
}

- (void)setNavTitleView:(NSString *)title viewController:(UIViewController *)viewController fontColor:(UIColor *)fontColor fontSize:(CGFloat)fontsize
{
    NSMutableDictionary *navTitleAttrs = [NSMutableDictionary dictionary];
    navTitleAttrs[NSForegroundColorAttributeName] = fontColor;
    navTitleAttrs[NSFontAttributeName] = [UIFont systemFontOfSize:fontsize];
    
    NSMutableAttributedString *navAttrTitle = [[NSMutableAttributedString alloc]initWithString:title attributes:navTitleAttrs];
    
    CGPoint centerPoint = CGPointMake(FFScreenWidth * 0.5, FFScreenHeight * 0.5);
    
    UILabel *navTitleLabel = [[UILabel alloc]init];
    navTitleLabel.attributedText = navAttrTitle;
    
    navTitleLabel.textAlignment = NSTextAlignmentCenter;
    
    CGSize navTitleSize = [navTitleLabel sizeThatFits:CGSizeMake(100, 65)];
    
    UIView *navTitleView = [[UIView alloc]init];
    navTitleView.center = centerPoint;
    navTitleView.bounds = CGRectMake(0, 0, navTitleSize.width, navTitleSize.height);
    [navTitleView addSubview:navTitleLabel];
    navTitleLabel.frame = navTitleView.bounds;
//    UIView *bottomView = [[UIView alloc]initWithFrame:CGRectMake(0, navTitleView.frame.size.height, navTitleView.frame.size.width, 1)];
//    bottomView.backgroundColor = [UIColor whiteColor];
//    [navTitleView addSubview:bottomView];
    
    viewController.navigationItem.titleView = navTitleView;
}

- (void)setNavRightItemWithVc:(UIViewController *) viewController title:(NSString *)title target:(id)target action:(SEL)action
{
    viewController.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:title style:UIBarButtonItemStylePlain target:target action:action];
}

@end
